package richbar.com.richbar.activity.me;

import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.RecyclerView;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.common.base.BaseActivity;
import com.common.help.RecycleViewHelp;
import java.util.ArrayList;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
import richbar.com.richbar.R;
import richbar.com.richbar.bean.MyExchangeBean;
import richbar.com.richbar.help.TitleHelp;

/**
 * Created by Administrator on 2018/11/30.
 * 我的兑换
 */

public class MyExchangeAc extends BaseActivity {
    @BindView(R.id.swipe)
    SwipeRefreshLayout swipe;
    @BindView(R.id.recycleView)
    RecyclerView recycleView;
    private NewsAdapter adapter;

    @Override
    public int initLayout() {
        return R.layout.ac_my_exchange;
    }

    @Override
    public void initTitle() {
        new TitleHelp(this).setTitle("我的兑换");
    }

    @Override
    public void initView() {
        ButterKnife.bind(this);
        swipe.setColorSchemeResources(R.color.blue);
        swipe.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
            @Override
            public void onRefresh() {

            }
        });
//        swipe.setRefreshing(true);
        List<MyExchangeBean> list=new ArrayList<>();
        list.add(new MyExchangeBean("产品名称:汽车坐垫","兑换时间:2018-11-30","兑换价格:500","运    费:50","状    态:待发货"));
        list.add(new MyExchangeBean("产品名称:汽车坐垫","兑换时间:2018-11-30","兑换价格:500","运    费:50","状    态:待发货"));
        list.add(new MyExchangeBean("产品名称:汽车坐垫","兑换时间:2018-11-30","兑换价格:500","运    费:50","状    态:待发货"));
        list.add(new MyExchangeBean("产品名称:汽车坐垫","兑换时间:2018-11-30","兑换价格:500","运    费:50","状    态:待发货"));
        list.add(new MyExchangeBean("产品名称:汽车坐垫","兑换时间:2018-11-30","兑换价格:500","运    费:50","状    态:待发货"));
        adapter = new NewsAdapter(R.layout.my_exchange_item,list);
        RecycleViewHelp.setManager(recycleView,this);
        recycleView.setAdapter(adapter);
        adapter.openLoadMore(1,true);
        adapter.setOnLoadMoreListener(new BaseQuickAdapter.RequestLoadMoreListener() {
            @Override
            public void onLoadMoreRequested() {

            }
        });
    }

    @Override
    public void initData() {

    }

    private class NewsAdapter extends BaseQuickAdapter<MyExchangeBean> {
        public NewsAdapter(int layoutResId, List<MyExchangeBean> data) {
            super(layoutResId, data);

        }

        @Override
        protected void convert(BaseViewHolder holder, final MyExchangeBean bean) {
            holder.setText(R.id.tv_1, bean.getName());
            holder.setText(R.id.tv_2, bean.getTime());
            holder.setText(R.id.tv_3, bean.getPrice());
            holder.setText(R.id.tv_4, bean.getFreight());
            holder.setText(R.id.tv_5, bean.getState());
//            View view = holder.getView(R.id.iv);
//            view.setBackgroundColor(ItemColorSet.getColor(NewsActivity.this,holder.getLayoutPosition()));
//            holder.itemView.setOnClickListener(new View.OnClickListener() {
//                @Override
//                public void onClick(View v) {
//                    WebActivity.start(NewsActivity.this,bean.getUrl(),"新闻详情");
//                }
//            });
        }
    }
}
